<?php

/**
 * @author Sven-Ove Bjerkan
 * @copyright 2008
 */

class Login {
	/**
	 * Check if a login is valid
	 * @param $username the username
	 * @param $password the password
	 * @return The users userID, or -1 on failure
	 */
	public function checkLogin($username, $password) {
		require_once('../class/db.class.php');

		$query = "SELECT userID, realname FROM users WHERE username=? AND password=?";
		$query = DB::singleton()->getQuery($query, array('s', 's'), array($username, $password));
		$res = DB::singleton()->execSelectQuery($query);
		if ($res['numRows'] == 1) return $res['result'][0];
		else return -1;
	}
}

?>